package com.yulian.web.handler.impl;

import com.yulian.web.handler.UserHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.yulian.web_api.system_management.UserManager;

import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.web.RoutingContext;
import io.vertx.pgclient.PgPool;

public class UserHandlerImpl implements UserHandler {
	private final Logger logger = LoggerFactory.getLogger(UserHandlerImpl.class);
	private final PgPool pool;
	private final JWTAuth jwt;


	public UserHandlerImpl(PgPool pool,JWTAuth jwt){
		logger.info("in constructor of UserHandlerImpl");
		this.pool = pool;
		this.jwt = jwt;
	}
	@Override
	public void handle(RoutingContext req) {
		JsonObject bodyJSObj = req.body().asJsonObject();
		UserManager userManager = new UserManager();
		switch(req.request().uri().toString()) {
//		case "/user/register":
//			userManager.registerUserWithPhone(pool, bodyJSObj)
//			.onSuccess(responseJSObj -> {
//				req.response()
//				.putHeader("content-type", "application/json")
//				.end(responseJSObj.toString());
//			})
//			.onFailure(err ->{
//				JsonObject responseJSObj = new JsonObject();
//				responseJSObj.put("code", -1).put("msg","错误: "+err.getMessage());
//				req.response()
//				.putHeader("content-type", "application/json")
//				.end(responseJSObj.toString());
//			});
//			break;
		case "/user/web_signin":
//			userManager.webSignin(pool, redis,jwt,server_authjwt, bodyJSObj)
//			.onSuccess(responseJSObj -> {
//				req.response()
//				.putHeader("content-type", "application/json")
//				.end(responseJSObj.toString());
//			})
//			.onFailure(err ->{
//				JsonObject responseJSObj = new JsonObject();
//				responseJSObj.put("code", -1).put("msg","错误: "+err.getMessage());
//				req.response()
//				.putHeader("content-type", "application/json")
//				.end(responseJSObj.toString());
//			});
//			break;
		}
	}
}
